package com.topscore.uke.mvp.presenters;

import com.topscore.uke.entities.AddressListItem;
import com.topscore.uke.mvp.contractors.GetMemberAddressListContractor;
import com.topscore.uke.mvp.model.GetMemberAddressListModel;
import com.topscore.uke.network.BaseResponse;

import java.util.List;

/**
 * Created by 71468 on 2017/10/19.
 */

public class GetAddressListPresenter implements GetMemberAddressListContractor,GetMemberAddressListContractor.Presenter {
    private View mView;
    private Listener mListener;

    public GetAddressListPresenter(View view) {
        this.mView = view;
        this.mListener = new Listener() {
            @Override
            public void onGetListSuccess(BaseResponse<List<AddressListItem>> response) {
                mView.onGetAddressListSuccess(response.getData());
            }

            @Override
            public void onError(int errorCode, String errorMessage) {
                mView.onFail(errorCode,errorMessage);
            }

            @Override
            public void onComplete() {
                mView.onLoadFinished();
            }
        };
    }

    @Override
    public void getAddressList(String phone) {
        new GetMemberAddressListModel(phone).getAddresses(mListener);
    }
}
